﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Microsoft.Office.OneNote
{
    [OneNoteXmlElement("OEChildren")]
    internal sealed class OEChildren : OneNoteObject, IOneNoteObjectWithChildren
    {
        private readonly OneNotePageObjectStorage _storage = new OneNotePageObjectStorage();
        private readonly OneNoteObjectCollection<OneNoteOutlineElement> _elements;

        public OEChildren()
        {
            _elements = new OneNoteObjectCollection<OneNoteOutlineElement>(_storage);
        }

        public OneNoteObjectCollection<OneNoteOutlineElement> OutlineElements
        {
            get { return _elements; }
        }

        void IOneNoteObjectWithChildren.UpdateFrom(IEnumerable<XElement> elements)
        {
            _storage.UpdateFrom(elements);
        }

        internal static OneNoteProperty RegisterProperty<TOwner>() where TOwner : OneNoteObject
        {
            return OneNoteProperty.Register("OEChildren", typeof(OEChildren), typeof(TOwner),
                DefaultValueProvider.NewInstance<OEChildren>());
        }
    }
}
